//
//  MainNavViewController.swift
//  IFXY
//
//  Created by LiuXing on 2016/12/30.
//  Copyright © 2016年 IFly. All rights reserved.
//

import UIKit

class MainNavViewController: UINavigationController {

    override func viewDidLoad() {
        // Do any additional setup after loading the view.
        super.viewDidLoad()
    }
    
    private lazy var backButtonItem: UIBarButtonItem = {
        let backButton = UIBarButtonItem(image: UIImage(named:"back"), style: .plain, target: self, action: #selector(pop))
        backButton.tintColor = UIColor.white
        return backButton
    }()
    
    @objc private func pop() {
        self.popViewController(animated: true)
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if self.childViewControllers.count > 0 {
            viewController.navigationItem.leftBarButtonItem = backButtonItem
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: animated)
    }
}
